﻿using System;
using System.Collections.Generic;
using System.Text;
using MaximServices.Model;
using MaximServices.Repository;

namespace MaximServices.Services
{
    public class MockCacheServices
    {
        private MockCacheRepository _testRepository;

        public MockCacheServices(MockCacheRepository testRepository)
        {
            _testRepository = testRepository;
        }

        /// <summary>
        /// 通过缓存进行锁
        /// </summary>
        /// <param name="mockCache"></param>
        /// <param name="timeout"></param>
        /// <param name="continueIfExists"></param>
        /// <returns></returns>
        public T LockByCache<T>(Func<T> action, MockCache mockCache, int timeout, bool continueIfExists)
        {
            return _testRepository.LockByCache(action, mockCache, timeout, continueIfExists);
        }

        public MockCache FindCache(string cacheKey)
        {
            return _testRepository.FindCache(cacheKey);
        }
    }
}
